package net.xumf.support.enums;

import lombok.Getter;
import net.xumf.support.exception.NotFoundEnumInfoException;

import java.util.Arrays;

/**
 * 连接池类型
 */
@Getter
public enum PoolTypeEnum {

    C3P0(10, "c3p0"),
    DRUID(11, "druid"),
    ;

    private int code;
    private String msg;

    PoolTypeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static PoolTypeEnum getByCode(int code) {

        return Arrays.stream(values()).filter(o -> o.code == code).findAny()
                .orElseThrow(() -> new NotFoundEnumInfoException(CodeEnum.ENUM_NOT_FOUND_ERROR));
    }
}
